﻿use persons
go
------------------12---------------------------------------------------------------
/*Find the most often met surname fathers*/
SELECT TOP 1 
[Person].[LastName], 
COUNT([Person].[LastName]) AS [AMOUNT]
FROM [dbo].[Person] INNER JOIN [dbo].[Person] AS [FATHER] ON [Person].[ID]=[FATHER].[fk_fatherId]
GROUP BY [Person].[LastName]
ORDER BY  [AMOUNT] DESC

SELECT TOP 1 
[Person].[LastName], 
COUNT([Person].[LastName]) AS [AMOUNT]
FROM [dbo].[Person],[dbo].[Person] AS [FATHER] 
WHERE [Person].[ID]=[FATHER].[fk_fatherId]
GROUP BY [Person].[LastName]
ORDER BY  [AMOUNT] DESC
